package com.ihr360.authority.sharing.privilege;

import com.ihr360.authority.sharing.service.AuthUserResourceService;
import com.ihr360.commons.model.type.AccessPrivilege;
import com.ihr360.validation.ValidationUtils;

public class UpdateOnePrivilege<ID> extends GetOnePrivilege<ID> {

    public UpdateOnePrivilege(ID id, AuthUserResourceService authUserResourceService, IAccessControlClass iAccessControlClass) {
        super(id, authUserResourceService,iAccessControlClass);
        this.method = AccessControlMethod.METHODS.update;
    }

    @Override
    public void validate() {
        if (isAccessControl()) {
            ValidationUtils.rejectIfEmpty(privilege, null, "您没有权限进行此操作");
            ValidationUtils.rejectNotEqual(null, "您没有权限进行此操作", privilege, AccessPrivilege.Privilege.OWNER, AccessPrivilege.Privilege.EDITABLE);
        }
    }

}